<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String PATH = request.getContextPath();
%>

<jsp:include page="../common/header.jsp">
	<jsp:param name="title" value="通知公告"/>
</jsp:include>

<script type="text/javascript" src="<%=PATH%>/public/js/modern/slider.js"></script>

<script src="<%=PATH%>/public/js/DatePicker/WdatePicker.js"></script>

<div class="page with-sidebar">
	<div class="page-header">
        <div class="page-header-content">
            <h1 style="width:500px">任务管理<small>案例</small></h1>
            <a class="back-button big page-back" href="<%=PATH %>"></a>
        </div>
    </div>
    
    <div class="page-sidebar">
    	<ul>
    		<li class="sticker sticker-color-orangeDark">
    			<a href="#touse">使用说明</a>
    		</li>
			<li class="sticker sticker-color-yellow">
    			<a href="#add">新增任务</a>
    		</li>
			<li class="sticker sticker-color-green">
    			<a href="#list">查看任务</a>
    		</li>
			<li class="sticker sticker-color-green">
    			<a href="#update">更新任务属性</a>
    		</li>
			<li class="sticker sticker-color-green">
    			<a href="#apply">申请删除任务</a>
    		</li>
			<li class="sticker sticker-color-green">
    			<a href="#passApply">同意删除任务</a>
    		</li>
    	</ul>
    </div>
    
    <div class="page-region">
    	<div class="grid" style="padding-left:20px;">
    		<div class="row">
				   <h2 id="touse">使用说明</h2>
				   <div>
				   		1. 这里的任何操作都是以JSON格式返回结果数据<br />
				   </div>
    		</div>
    		<br />
			
    		<div class="row">
  				  <h2 id="add">新增任务</h2>
				  <div class="hero-unit">
					1.标题不能为空<br />
					2.开始时间不能为空，结束时间不能为空<br />
					3.默认的任务进度为0
				  </div>
  				  <div>
  				  	<form action="<%=PATH %>/task/add.htm" method="post">
  				  		<div class="row">
  				  			<h4 class="span2">任务标题：</h4>
							<div class="input-control text span7">
								<input type="text" name="task.title" placeholder="任务的标题..."/>
							</div>
  				  		</div>
						
						<div class="row">
  				  			<h4 class="span2">任务执行者：</h4>
							<div class="input-control textarea span7">
								<input type="text" name="workerId" placeholder="任务执行者，这里填写的是User的id属性..."/>
							</div>
  				  		</div>
						
						<div class="row">
  				  			<h4 class="span2">任务开始时间：</h4>
							<div class="span7">
								<input class="Wdate" name="startDate" type="text" value="" onClick="WdatePicker()">
							</div>
  				  		</div>
						
						<div class="row">
  				  			<h4 class="span2">任务结束时间：</h4>
							<div class="span7">
								<input class="Wdate" name="endDate" type="text" value="" onClick="WdatePicker()">
							</div>
  				  		</div>
						
						<div class="row">
  				  			<h4 class="span2">任务等级：</h4>
							<div class="input-control select span7">
								<select name="task.level">
									<option value="0">普通</option>
									<option value="1">重要</option>
									<option value="2">十分重要</option>
								</select>
							</div>
  				  		</div>
						
						<div class="row">
							<input type="hidden" name="task.status" id="myStatus" value="0"/>
  				  			<h4 class="span2">任务进度：</h4>
							<div class="input-control textarea span7">
								<div class="span6" style="padding-top:12px;">
									<div id="slider1" class="slider" data-param-init-value="0"></div>
								</div>
								<h4 id="task_status" class="span1">0%</h4>
							</div>
  				  		</div>
						
						<div class="row">
							<input type="submit" class="big place-right bg-color-pink" value="保存"/>
						</div>
  				  	</form>
  				  </div>
    		</div>
			<br />
			
			<div class="row">
				<h2 id="list">查看任务</h2>
				
				<div class="hero-unit">
					1.可以查看某个职员或者某个部门的任务
				</div>
				
				<div class="grid">
					<div class="row">
			  			<h4 class="span2">职员id：</h4>
						<div class="input-control text span7">
							<input id="workerId" type="text" name="workerId" placeholder="职员id..."/>
						</div>
			  		</div>
					
					<div class="row">
			  			<h4 class="span2">部门id：</h4>
						<div class="input-control text span7">
							<input id="did" type="text" name="id" placeholder="部门id..."/>
						</div>
			  		</div>
					
					<div class="row">
						<button class="big place-right bg-color-blue" onclick="listTask();">浏览</button>
						<a href="#" id="task_list" target="_blank" class="big place-right" style="display:none;">
							<span id="task_list_span">搜索</span>
						</a>
					</div>
				</div>
			</div>
			<br />
			
			<div class="row">
				<h2 id="update">更新任务属性</h2>
				
				<div class="hero-unit">
					1.更新一个任务的属性：<br />
					 * 		任务进度（status）<br />
					 * 		任务等级（level）<br />
					 * 		申请删除任务（trash）<br />
					 * 		任务备注（message）<br />
				</div>
				
				<div class="grid">
					<div class="row">
			  			<h4 class="span2">目标Task ID：</h4>
						<div class="input-control text span7">
							<input id="taskId" type="text" placeholder="需要更改的taskId..."/>
						</div>
			  		</div>
					
					<div class="row">
			  			<h4 class="span2">更新类型：</h4>
						<div class="input-control select span7">
							<select id="updateType">
								<option value="0">任务进度</option>
								<option value="1">任务等级</option>
								<option value="2">申请删除任务</option>
								<option value="3">任务备注</option>
							</select>
						</div>
			  		</div>
					
					<div class="row">
			  			<h4 class="span2">更新内容：</h4>
						<div class="input-control text span7">
							<input id="updateValue" type="text" placeholder="输入更新内容..."/>
						</div>
			  		</div>
					
					<div class="row">
						<button class="big place-right bg-color-blue" onclick="updateTask();">浏览</button>
						<a href="#" id="task_update" target="_blank" class="big place-right" style="display:none;">
							<span id="task_update_span">搜索</span>
						</a>
					</div>
				</div>
			</div>
			<br />
			
			<div class="row">
				<h2 id="apply">申请删除任务</h2>
				
				<div class="hero-unit">
					1.此功能请在<a href="#update">“更改任务属性”</a>一栏中选择“申请删除任务”完成
				</div>
			</div>
			<br />
			
			<div class="row">
  				  <h2 id="passApply">同意删除任务</h2>
				  <div class="hero-unit">
					1.输入申请记录的id，就可以同意删除任务了<br />
					2.任务删除后，trash字段=1<br />
					3.需要部门主管或者总管理员的权限
				  </div>
  				  <div class="grid">
  				  	<div class="row">
						<h4 class="span2">申请记录id:</h4>
						<div class="input-control text span7">
							<input id="applyId" type="text" placeholder="id必须是数字且大于0..." />
						</div>
					</div>
					
					<div class="row">
						<button class="big place-right bg-color-blue" onclick="passApply();">同意</button>
						<a href="#" id="task_pass" target="_blank" class="big place-right" style="display:none;">
							<span id="task_pass_span">搜索</span>
						</a>
					</div>
  				  </div>
    		</div>
			
    	</div>
    </div>
</div>

<script>
	$(function(){
        $("#slider1").on("change", function(e, val){
            color = 'red';
            if (val > 30) {
                color = 'orange';
            }
            if (val > 70) {
                color = 'green';
            }
            $("#task_status").html(val+"%");
			$("#myStatus").val(val);
			
            $(this).children(".complete").css("background-color",  color);
        });
    });
	
	function deleteNotify(){
		var key = $("#key").val();
		
		if(Number(key) > 0){
			if(confirm("真的要删除这条公告吗？")){
				$("#search_a").attr("href", "<%=PATH %>/notify/delete.htm?id="+key);
				$("#search_span").trigger("click");
			}
			
		}else{
			alert("输入有误！id必须是数字且大于0");
		}
		return true;
	}
	
	function listTask(){
		var page = $("#workerId").val();
		var size = $("#did").val();
		$("#task_list").attr("href", "<%=PATH %>/task/list.htm?format=1&workerId="+page+"&id="+size);
		$("#task_list_span").trigger("click");
		
		return true;
	}
	
	/**
	 * 更新一个任务属性
	 */
	function updateTask(){
		var id = $("#taskId").val();
		var page = $("#updateType").val();
		var size = $("#updateValue").val();
		$("#task_update").attr("href", "<%=PATH %>/task/update.htm?format=1&id="+id+"&updateType="+page+"&updateValue="+size);
		$("#task_update_span").trigger("click");
		
		return true;
	}
	
	/**
	 * 同意任务的删除申请
	 */
	function passApply(){
		var id = $("#applyId").val();
		$("#task_pass").attr("href", "<%=PATH %>/task/passTrashApply.htm?format=1&id="+id);
		$("#task_pass_span").trigger("click");
		
		return true;
	}
</script>

<%@ include file="../common/footer.jsp" %>